﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace _18miljard.Config
{
	public class BotIpCollection : ConfigurationElementCollection
	{
		public BotIp this[int index]
		{
			get { return base.BaseGet(index) as BotIp; }
			set
			{
				if (base.BaseGet(index) != null)
					base.BaseRemoveAt(index);

				this.BaseAdd(index, value);
			}
		}

		public new BotIp this[string key]
		{
			get { return base.BaseGet(key) as BotIp; }
		}

		public bool Contains(string ip)
		{
			if (ip == null)
				return false;

			return (base.BaseGet(ip) != null);
		}

		protected override ConfigurationElement CreateNewElement()
		{
			return new BotIp();
		}

		protected override object GetElementKey(ConfigurationElement element)
		{
			return ((BotIp)element).Ip;
		}

	}
}
